package com.ecloud.gardenscenter.config;


import com.ecloud.gardenscenter.mqtt.MqttClientFactory;
import com.ecloud.gardenscenter.mqtt.MqttTemplate;
import com.ecloud.gardenscenter.service.mqtt.MqttCallBackService;
import org.eclipse.paho.mqttv5.common.MqttException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Squbi
 */
@Configuration
public class MqttConfig {
    @Bean
    public MqttTemplate template(MqttClientFactory factory, MqttCallBackService mqttCallBackService) {
        MqttTemplate template = null;
        try {
            template = new MqttTemplate(factory, "SERVER", mqttCallBackService);
        } catch (MqttException e) {
            e.printStackTrace();
        }
        return template;
    }
}
